package com.runtime.area.controller;

import com.alibaba.fastjson.JSON;
import com.runtime.area.service.AreaService;
import com.runtime.bean.Tblarea;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    @GetMapping("findAll")
    public String findAll(){
        List<Tblarea> list = areaService.findAll();
        String json = JSON.toJSONString(list);
        return json;
    }

    @GetMapping("findById/{areaId}")
    public Tblarea findById(@PathVariable("areaId") long areaId){
        Tblarea tblarea = areaService.findById(areaId);
        return tblarea;
    }
}
